﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using AspNetCs.Model;
using AspNetCs.Common;
using AspNetCs.Config;


public partial class Agent_Agent_Login : Admin_BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //IsExitAgent();
        if(!IsPostBack)
        {
        
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        AgentBLL bll = new AgentBLL();
        string SessionCode = "";
        if (Session["VerifyCode"] != null)
        {
            SessionCode = Session["VerifyCode"].ToString().Trim().ToLower();

        }
        else
        {
            Response.Write("<script>alert('验证码有误,返回后请刷新页面重新再试');history.back();</script>");
            Response.End();

        }


        string PutCode = CheckCode.Text.Trim().ToLower();
        if (SessionCode != PutCode)
        {
            Response.Write("<script>alert('请输入正确的验证码');history.back();</script>");
            Response.End();
        }

        AgentModel model = new AgentModel();
        model.AgentUserName = StringHelper.HtmlEncrypt(UserName.Text.Trim());
        model.AgentPwd = StringHelper.HtmlEncrypt(Password.Text.Trim()); ;
        if (bll.AgentLogin(model) == 0)
        {
            Response.Redirect("Default.Aspx");
            Response.End();

        }
        else
        {
            Response.Write("<script>alert('请不要非法尝试登录后台!!');history.back();</script>");
            Response.End();
        }


    }
}
